package org.example.com;

import org.apache.ibatis.annotations.Mapper;
import org.example.com.RocketMq.dto.Credit;
import org.example.com.RocketMq.dto.UserCharge;
import org.example.com.RocketMq.mapper.CreditMapper;
import org.example.com.RocketMq.mapper.MqTransactionLogMapper;
import org.example.com.RocketMq.mapper.UserChargeMapper;
import org.example.com.RocketMq.service.RocketService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest
public class testBoot {

//    @Autowired(required = false)
//    private MqTransactionLogMapper mqTransactionLogMapper;
    @Autowired
    private UserChargeMapper userMapper;
    @Autowired
    private CreditMapper creditMapper;
    @Autowired
    private RocketService rocketService;
    @Test
    public void test() {
        System.out.println("Spring Boot Test!");
    }

    @Test
    public void addBalance(){
        UserCharge userCharge = new UserCharge();
        userCharge.setUserId("6");
        userCharge.setChargeAmount(new BigDecimal(9.99));
        userCharge.setCreateTime(new Date());
        userCharge.setLastLoginTime(new Date());
        Integer integer = userMapper.addUserCharge(userCharge);
        System.out.println(integer);

    }

    @Test
    public void addCredit(){
        Credit credit = new Credit();
        credit.setId(2);
        credit.setUserId(2);
        credit.setUserName("name");
        credit.setIntegration(22);
        Integer integer1 = creditMapper.addCredit(credit);
        System.out.println(integer1);

    }

    @Test
    public void selectCredit(){
        Credit credit = new Credit();
        credit.setId(null);
        credit.setUserName("name");
        credit.setIntegration(22);
        List<Credit> credit1 = creditMapper.selectCredit(credit);
        System.out.println(credit1.toString());
        Map<String, Object> stringObjectMap = rocketService.selectByPrimaryKey("3");
        for (String s : stringObjectMap.keySet()) {
            System.out.println(stringObjectMap.get(s));
        }
    }
}
